package lily.phs.child;


import lily.phs.object.NewBornChild;
import lily.phs.urh.R;
import lily.ui.control.MyPopupWindow;



import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.InputType;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;

/**
 * @author chen
 *该类用于显示“新生儿家庭访视记录表”中后半部分的内容
 */
public class NewChildBornView_Two extends RelativeLayout implements OnFocusChangeListener,OnClickListener{
	Paint paint;
	private LinearLayout ll1;
	MyPopupWindow mPopupWindow;
	private int profileid=0;
	private RadioButton rb_mianse_hongrun,rb_mianse_huangran,rb_mianse_other,rb_mianbu,rb_qugan,rb_sizhi,rb_shouzu,
						rb_qianxin_zhengchang,rb_qianxin_penglong,rb_qianxin_aoxian,rb_qianxin_other,
						rb_yanwaiguan_no,rb_yanwaiguan_yes,rb_sizhi_no,rb_sizhi_yes,
						rb_ear_no,rb_ear_yes,rb_jbbk_no,rb_jbbk_yes,
						rb_nose_no,rb_nose_yes,rb_skin_no,rb_skin_shizhen,rb_skin_milan,rb_skin_other,
						rb_oral_no,rb_oral_yes,rb_gangmen_no,rb_gangmen_yes,
						rb_card_no,rb_card_yes,rb_wszq_no,rb_wszq_yes,
						rb_fubu_no,rb_fubu_yes,rb_jizhu_no,rb_jizhu_yes,
						rb_qibu_weituo,rb_qibu_tuoluo,rb_qibu_youshenchu,rb_qibu_other,
						rb_zhuanzhen_no,rb_zhuanzhen_yes;
	private EditText et_mianse_other,
					 et_qianxin_left,et_qianxin_right,et_qianxin_other,
					 et_yanwaiguan_yes,et_sizhi_yes,
					 et_ear_yes,et_jbbk_yes,
					 et_nose_yes,
					 et_oral_yes,et_gangmen_yes,
					 et_card_yes,et_wszq_yes,
					 et_fubu_yes,et_jizhu_yes,
					 et_qibu_other,
					 et_zhuanzhen_reason,et_zhuanzhen_inst,
					 et_now_date,et_next_place,
					 et_next_date,et_doctor;
	private CheckBox cb_weiyang,cb_fayu,cb_fangbing,cb_yufang,cb_oral;
	
	private RadioGroup rg_mianse,rg_hd,rg_qianxin,rg_eye,rg_leg,rg_ear,rg_jbbk,rg_nose,rg_skin,
					   rg_oral,rg_gangmen,rg_card,rg_wszq,rg_fubu,rg_jizhu,rg_qidai,rg_zhuanzhen;
	private Context myContext;
	View v;
	NewBornChild nbc;
	
	public NewChildBornView_Two(Context context,int pro) {
		super(context);
		myContext=context;
		this.profileid=pro;
		paint=new Paint();
		paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.BLACK);        
	}
	
	/**
	 * 该函数用于初始化本界面中的所有控件
	 */
	public void findWeigt(){
		LayoutInflater factory = LayoutInflater.from(myContext);
        v = factory.inflate(R.layout.new_child_fam_ask_2, null);
        ll1=(LinearLayout)v.findViewById(R.id.ll);
        rg_mianse=(RadioGroup)v.findViewById(R.id.rg_newchild_mianse);
		rb_mianse_hongrun=(RadioButton)v.findViewById(R.id.rb_newchild_mianse_hongrun);
		rb_mianse_hongrun.requestFocus();
		rb_mianse_huangran=(RadioButton)v.findViewById(R.id.rb_newchild_mianse_huangran);
		rb_mianse_other=(RadioButton)v.findViewById(R.id.rb_newchild_mianse_other);
		et_mianse_other=(EditText)v.findViewById(R.id.et_newchild_mianse_qita);
		et_mianse_other.setInputType(InputType.TYPE_NULL);
		rg_hd=(RadioGroup)v.findViewById(R.id.rg_newchild_hd);
		rb_mianbu=(RadioButton)v.findViewById(R.id.rb_newchild_hd_mianbu);
		rb_qugan=(RadioButton)v.findViewById(R.id.rb_newchild_hd_qugan);
		rb_sizhi=(RadioButton)v.findViewById(R.id.rb_newchild_hd_sizhi);
		rb_shouzu=(RadioButton)v.findViewById(R.id.rb_newchild_hd_shouzu);
		et_qianxin_left=(EditText)v.findViewById(R.id.et_newchild_qianxin_left);
		et_qianxin_right=(EditText)v.findViewById(R.id.et_newchild_qianxin_right);
		rg_qianxin=(RadioGroup)v.findViewById(R.id.rg_newchild_qianxin);
		rb_qianxin_zhengchang=(RadioButton)v.findViewById(R.id.rb_newchild_qianxin_zhengchang);
		rb_qianxin_penglong=(RadioButton)v.findViewById(R.id.rb_newchild_qianxin_penglong);
		rb_qianxin_aoxian=(RadioButton)v.findViewById(R.id.rb_newchild_qianxin_aoxian);
		rb_qianxin_other=(RadioButton)v.findViewById(R.id.rb_newchild_qianxin_other);
		et_qianxin_other=(EditText)v.findViewById(R.id.et_newchild_qianxin_other);
		rg_eye=(RadioGroup)v.findViewById(R.id.rg_newchild_yanwaiguan);
		rb_yanwaiguan_no=(RadioButton)v.findViewById(R.id.rb_newchild_yanwaiguan_no);
		rb_yanwaiguan_yes=(RadioButton)v.findViewById(R.id.rb_newchild_yanwaiguan_yes);
		et_yanwaiguan_yes=(EditText)v.findViewById(R.id.et_newchild_yanwaiguan_yes);
		rg_leg=(RadioGroup)v.findViewById(R.id.rg_newchild_sizhi);
		rb_sizhi_no=(RadioButton)v.findViewById(R.id.rb_newchild_sizhi_no);
		rb_sizhi_yes=(RadioButton)v.findViewById(R.id.rb_newchild_sizhi_yes);
		et_sizhi_yes=(EditText)v.findViewById(R.id.et_newchild_sizhi_yes);
		rg_ear=(RadioGroup)v.findViewById(R.id.rg_newchild_ear);
		rb_ear_no=(RadioButton)v.findViewById(R.id.rb_newchild_ear_no);
		rb_ear_yes=(RadioButton)v.findViewById(R.id.rb_newchild_ear_yes);
		et_ear_yes=(EditText)v.findViewById(R.id.et_newchild_ear_yes);
		rg_jbbk=(RadioGroup)v.findViewById(R.id.rg_newchild_jbbk);
		rb_jbbk_no=(RadioButton)v.findViewById(R.id.rb_newchild_jbbk_no);
		rb_jbbk_yes=(RadioButton)v.findViewById(R.id.rb_newchild_jbbk_yes);
		et_jbbk_yes=(EditText)v.findViewById(R.id.et_newchild_jbbk_yes);
		rg_nose=(RadioGroup)v.findViewById(R.id.rg_newchild_nose);
		rb_nose_no=(RadioButton)v.findViewById(R.id.rb_newchild_nose_no);
		rb_nose_yes=(RadioButton)v.findViewById(R.id.rb_newchild_nose_yes);
		et_nose_yes=(EditText)v.findViewById(R.id.et_newchild_nose_yes);
		rg_skin=(RadioGroup)v.findViewById(R.id.rg_newchild_skin);
		rb_skin_no=(RadioButton)v.findViewById(R.id.rb_newchild_skin_no);
		rb_skin_shizhen=(RadioButton)v.findViewById(R.id.rb_newchild_skin_shizhen);
		rb_skin_milan=(RadioButton)v.findViewById(R.id.rb_newchild_skin_milan);
		rb_skin_other=(RadioButton)v.findViewById(R.id.rb_newchild_skin_other);
		rg_oral=(RadioGroup)v.findViewById(R.id.rg_newchild_oral);
		rb_oral_no=(RadioButton)v.findViewById(R.id.rb_newchild_oral_no);
		rb_oral_yes=(RadioButton)v.findViewById(R.id.rb_newchild_oral_yes);
		et_oral_yes=(EditText)v.findViewById(R.id.et_newchild_oral_yes);
		rg_gangmen=(RadioGroup)v.findViewById(R.id.rg_newchild_gangmen);
		rb_gangmen_no=(RadioButton)v.findViewById(R.id.rb_newchild_gangmen_no);
		rb_gangmen_yes=(RadioButton)v.findViewById(R.id.rb_newchild_gangmen_yes);
		et_gangmen_yes=(EditText)v.findViewById(R.id.et_newchild_gangmen_yes);
		rg_card=(RadioGroup)v.findViewById(R.id.rg_newchild_card);
		rb_card_no=(RadioButton)v.findViewById(R.id.rb_newchild_card_no);
		rb_card_yes=(RadioButton)v.findViewById(R.id.rb_newchild_card_yes);
		et_card_yes=(EditText)v.findViewById(R.id.et_newchild_card_yes);
		rg_wszq=(RadioGroup)v.findViewById(R.id.rg_newchild_wszq);
		rb_wszq_no=(RadioButton)v.findViewById(R.id.rb_newchild_wszq_no);
		rb_wszq_yes=(RadioButton)v.findViewById(R.id.rb_newchild_wszq_yes);
		et_wszq_yes=(EditText)v.findViewById(R.id.et_newchild_wszq_yes);
		rg_fubu=(RadioGroup)v.findViewById(R.id.rg_newchild_fubu);
		rb_fubu_no=(RadioButton)v.findViewById(R.id.rb_newchild_fubu_no);
		rb_fubu_yes=(RadioButton)v.findViewById(R.id.rb_newchild_fubu_yes);
		et_fubu_yes=(EditText)v.findViewById(R.id.et_newchild_fubu_yes);
		rg_jizhu=(RadioGroup)v.findViewById(R.id.rg_newchild_jizhu);
		rb_jizhu_no=(RadioButton)v.findViewById(R.id.rb_newchild_jizhu_no);
		rb_jizhu_yes=(RadioButton)v.findViewById(R.id.rb_newchild_jizhu_yes);
		et_jizhu_yes=(EditText)v.findViewById(R.id.et_newchild_jizhu_yes);
		rg_qidai=(RadioGroup)v.findViewById(R.id.rg_newchild_qidai);
		rb_qibu_weituo=(RadioButton)v.findViewById(R.id.rb_newchild_qidai_weituo);
		rb_qibu_tuoluo=(RadioButton)v.findViewById(R.id.rb_newchild_qidai_tuoluo);
		rb_qibu_youshenchu=(RadioButton)v.findViewById(R.id.rb_newchild_qidai_youshenchu);
		rb_qibu_other=(RadioButton)v.findViewById(R.id.rb_newchild_qidai_other);
		et_qibu_other=(EditText)v.findViewById(R.id.et_newchild_qidai_other);
		rg_zhuanzhen=(RadioGroup)v.findViewById(R.id.rg_newchild_zhuanzhen);
		rb_zhuanzhen_no=(RadioButton)v.findViewById(R.id.rb_newchild_zhuanzhen_no);
		rb_zhuanzhen_yes=(RadioButton)v.findViewById(R.id.rb_newchild_zhuanzhen_yes);
		et_zhuanzhen_reason=(EditText)v.findViewById(R.id.et_newchild_zhuanzhen_reason);
		et_zhuanzhen_inst=(EditText)v.findViewById(R.id.et_newchild_zhuanzhen_inst);
		cb_weiyang=(CheckBox)v.findViewById(R.id.cb_newchild_guide_weiyang);
		cb_fayu=(CheckBox)v.findViewById(R.id.cb_newchild_guide_fayu);
		cb_fangbing=(CheckBox)v.findViewById(R.id.cb_newchild_guide_fangbing);
		cb_yufang=(CheckBox)v.findViewById(R.id.cb_newchild_guide_yufangshanghai);
		cb_oral=(CheckBox)v.findViewById(R.id.cb_newchild_guide_oral);
		et_now_date=(EditText)v.findViewById(R.id.et_newchild_now_date);
		et_now_date.setInputType(InputType.TYPE_NULL);
		et_next_place=(EditText)v.findViewById(R.id.et_newchild_next_place);
		et_next_date=(EditText)v.findViewById(R.id.et_newchild_next_date);
		et_next_date.setInputType(InputType.TYPE_NULL);
		et_now_date.setOnClickListener(this);
		et_now_date.setOnFocusChangeListener(this);
		et_next_date.setOnClickListener(this);
		et_next_date.setOnFocusChangeListener(this);
		et_doctor=(EditText)v.findViewById(R.id.et_newchild_doctor);
		nbc=new NewBornChild(myContext);
		nbc.selectNewBornChild(profileid);
	}
	
	public void selectData(){
		nbc=new NewBornChild(myContext);
		nbc.selectNewBornChild(profileid);
	}
	
	public void addToView(){
		LayoutParams lp=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
		
		this.addView(v,lp);
		
		MyView mv=new MyView(myContext);
		this.addView(mv,lp);
	}
	
	/**
	 * 该函数用于通过数据库中的记录初始化各个控件的值
	 */
	public void initView(){
		if(nbc.getBoch_face()>0){
			switch(nbc.getBoch_face()){
			case 1:
				rg_mianse.check(0);
				rb_mianse_hongrun.setChecked(true);
				break;
			case 2:
				rg_mianse.check(1);
				rb_mianse_huangran.setChecked(true);
				break;
			case 3:
				rg_mianse.check(2);
				rb_mianse_other.setChecked(true);
				et_mianse_other.setText(nbc.getBoch_face_other());
				break;
			}
		}
		if(nbc.getBoch_icterus()>0){
			switch(nbc.getBoch_icterus()){
			case 1:
				rg_hd.check(0);
				rb_mianbu.setChecked(true);
				break;
			case 2:
				rg_hd.check(1);
				rb_qugan.setChecked(true);
				break;
			case 3:
				rg_hd.check(2);
				rb_sizhi.setChecked(true);
				break;
			case 4:
				rg_hd.check(3);
				rb_shouzu.setChecked(true);
				break;
			}
		}
		if(nbc.getBoch_bregma_left()>0){
			et_qianxin_left.setText(nbc.getBoch_bregma_left()+"");
		}
		if(nbc.getBoch_bregma_right()>0){
			et_qianxin_right.setText(nbc.getBoch_bregma_right()+"");
		}
		if(nbc.getBoch_bregma_choi()>0){
			switch(nbc.getBoch_bregma_choi()){
			case 1:
				rg_qianxin.check(0);
				rb_qianxin_zhengchang.setChecked(true);
				break;
			case 2:
				rg_qianxin.check(1);
				rb_qianxin_penglong.setChecked(true);
				break;
			case 3:
				rg_qianxin.check(2);
				rb_qianxin_aoxian.setChecked(true);
				break;
			case 4:
				rg_qianxin.check(3);
				rb_qianxin_other.setChecked(true);
				et_qianxin_other.setText(nbc.getBoch_bregma_other());
				break;
			}
		}
		if(nbc.getBoch_eye_appearance()>0){
			switch(nbc.getBoch_eye_appearance()){
			case 1:
				rg_eye.check(0);
				rb_yanwaiguan_no.setChecked(true);
				break;
			case 2:
				rg_eye.check(1);
				rb_yanwaiguan_yes.setChecked(true);
				et_yanwaiguan_yes.setText(nbc.getBoch_eye_appearance_abn());
				break;
			}
		}
		if(nbc.getBoch_legs()>0){
			switch(nbc.getBoch_legs()){
			case 1:
				rg_leg.check(0);
				rb_sizhi_no.setChecked(true);
				break;
			case 2:
				rg_leg.check(1);
				rb_sizhi_yes.setChecked(true);
				et_sizhi_yes.setText(nbc.getBoch_legs_abn());
				break;
			}
		}
		if(nbc.getBoch_ear_appearance()>0){
			switch(nbc.getBoch_ear_appearance()){
			case 1:
				rg_ear.check(0);
				rb_ear_no.setChecked(true);
				break;
			case 2:
				rg_ear.check(1);
				rb_ear_yes.setChecked(true);
				et_ear_yes.setText(nbc.getBoch_ear_appearance_abn());
				break;
			}
		}
		if(nbc.getBoch_neck_mass()>0){
			switch(nbc.getBoch_neck_mass()){
			case 1:
				rg_jbbk.check(0);
				rb_jbbk_no.setChecked(true);
				break;
			case 2:
				rg_jbbk.check(1);
				rb_jbbk_yes.setChecked(true);
				et_jbbk_yes.setText(nbc.getBoch_neck_mass_abn());
				break;
			}
		}
		if(nbc.getBoch_nose()>0){
			switch(nbc.getBoch_nose()){
			case 1:
				rg_nose.check(0);
				rb_nose_no.setChecked(true);
				break;
			case 2:
				rg_nose.check(1);
				rb_nose_yes.setChecked(true);
				et_nose_yes.setText(nbc.getBoch_nose_abn());
				break;
			}
		}
		if(nbc.getBoch_skin()>0){
			switch(nbc.getBoch_skin()){
			case 1:
				rg_skin.check(0);
				rb_skin_no.setChecked(true);
				break;
			case 2:
				rg_skin.check(1);
				rb_skin_shizhen.setChecked(true);
				break;
			case 3:
				rg_skin.check(2);
				rb_skin_milan.setChecked(true);
				break;
			case 4:
				rg_skin.check(3);
				rb_skin_other.setChecked(true);
				break;
			}
		}
		if(nbc.getBoch_oral()>0){
			switch(nbc.getBoch_oral()){
			case 1:
				rg_oral.check(0);
				rb_oral_no.setChecked(true);
				break;
			case 2:
				rg_oral.check(1);
				rb_oral_yes.setChecked(true);
				et_oral_yes.setText(nbc.getBoch_oral_abn());
				break;
			}
		}
		if(nbc.getBoch_anus()>0){
			switch(nbc.getBoch_anus()){
			case 1:
				Log.e("TEST1","rb_gangmen_no.isChecked()"+rb_gangmen_no.isChecked());
				rg_gangmen.check(0);
				rb_gangmen_no.setChecked(true);
				Log.e("TEST1","rb_gangmen_no.isChecked()"+rb_gangmen_no.isChecked());
				break;
			case 2:
				rg_gangmen.check(1);
				rb_gangmen_yes.setChecked(true);
				et_gangmen_yes.setText(nbc.getBoch_anus_abn());
				break;
			}
		}
		if(nbc.getBoch_card()>0){
			switch(nbc.getBoch_card()){
			case 1:
				rg_card.check(0);
				rb_card_no.setChecked(true);
				break;
			case 2:
				rg_card.check(1);
				rb_card_yes.setChecked(true);
				et_card_yes.setText(nbc.getBoch_card_abn());
				break;
			}
		}
		if(nbc.getBoch_genital()>0){
			switch(nbc.getBoch_genital()){
			case 1:
				rg_wszq.check(0);
				rb_wszq_no.setChecked(true);
				break;
			case 2:
				rg_wszq.check(1);
				rb_wszq_yes.setChecked(true);
				et_wszq_yes.setText(nbc.getBoch_genital_abn());
				break;
			}
		}
		if(nbc.getBoch_abdomen()>0){
			switch(nbc.getBoch_abdomen()){
			case 1:
				rg_fubu.check(0);
				rb_fubu_no.setChecked(true);
				break;
			case 2:
				rg_fubu.check(1);
				rb_fubu_yes.setChecked(true);
				et_fubu_yes.setText(nbc.getBoch_abdomen_abn());
				break;
			}
		}
		if(nbc.getBoch_spine()>0){
			switch(nbc.getBoch_spine()){
			case 1:
				rg_jizhu.check(0);
				rb_jizhu_no.setChecked(true);
				break;
			case 2:
				rg_jizhu.check(1);
				rb_jizhu_yes.setChecked(true);
				et_jizhu_yes.setText(nbc.getBoch_spine_abn());
				break;
			}
		}
		if(nbc.getBoch_umbilical()>0){
			switch(nbc.getBoch_umbilical()){
			case 1:
				rg_qidai.check(0);
				rb_qibu_weituo.setChecked(true);
				break;
			case 2:
				rg_qidai.check(1);
				rb_qibu_tuoluo.setChecked(true);
				break;
			case 3:
				rg_qidai.check(2);
				rb_qibu_youshenchu.setChecked(true);
				break;
			case 4:
				rg_qidai.check(3);
				rb_qibu_other.setChecked(true);
				et_qibu_other.setText(nbc.getBoch_umbilical_other());
				break;
			}
		}
		if(nbc.getBoch_refe_choi()>0){
			switch(nbc.getBoch_refe_choi()){
			case 1:
				rg_zhuanzhen.check(0);
				rb_zhuanzhen_no.setChecked(true);
				break;
			case 2:
				rg_zhuanzhen.check(1);
				rb_zhuanzhen_yes.setChecked(true);
				et_zhuanzhen_reason.setText(nbc.getBoch_refe_reasion());
				et_zhuanzhen_inst.setText(nbc.getBoch_refe_inst());
				break;
			}
		}
		if(nbc.getBoch_guide()!=null&&nbc.getBoch_guide().length()>0){
			String str[]=nbc.getBoch_guide().split(",");
			for(int i=0;i<str.length;i++){
				switch(Integer.parseInt(str[i])){
				case 1:
					cb_weiyang.setChecked(true);
					break;
				case 2:
					cb_fayu.setChecked(true);
					break;
				case 3:
					cb_fangbing.setChecked(true);
					break;
				case 4:
					cb_yufang.setChecked(true);
					break;
				case 5:
					cb_oral.setChecked(true);
					break;
				}
			}
		}
		et_now_date.setText(nbc.getBoch_now_date());
		et_next_place.setText(nbc.getBoch_next_place());
		et_next_date.setText(nbc.getBoch_next_date());
		et_doctor.setText(nbc.getBoch_doctor());
	}
	
	/**
	 * @return若保存成功返回true，若保存失败返回false
	 * 该函数用于将本界面中控件的值保存到数据库中
	 */
	public boolean saveView(){
		if(et_qianxin_left.getText().toString().replaceAll("\\s", "").length()>10||
				et_qianxin_left.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_qianxin_left.setError("数据超出范围");
			return false;
		}
		if(et_qianxin_right.getText().toString().replaceAll("\\s", "").length()>10||
				et_qianxin_right.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_qianxin_right.setError("数据超出范围");
			return false;
		}
		NewBornChild nbc=new NewBornChild(myContext);
		nbc.selectNewBornChild(profileid);
		if(rb_mianse_hongrun.isChecked()){
			nbc.setBoch_face(1);
		}
		else if(rb_mianse_huangran.isChecked()){
			nbc.setBoch_face(2);
		}
		else if(rb_mianse_other.isChecked()){
			nbc.setBoch_face(3);
			nbc.setBoch_face_other(et_mianse_other.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_mianbu.isChecked()){
			nbc.setBoch_icterus(1);
		}
		else if(rb_qugan.isChecked()){
			nbc.setBoch_icterus(2);
		}
		else if(rb_sizhi.isChecked()){
			nbc.setBoch_icterus(3);
		}
		else if(rb_shouzu.isChecked()){
			nbc.setBoch_icterus(4);
		}
		if(et_qianxin_left.getText().toString().replaceAll("\\s", "").length()>0){
			nbc.setBoch_bregma_left(Float.parseFloat(et_qianxin_left.getText().toString().replaceAll("\\s", "")));
		}
		if(et_qianxin_right.getText().toString().replaceAll("\\s", "").length()>0){
			nbc.setBoch_bregma_right(Float.parseFloat(et_qianxin_right.getText().toString().replaceAll("\\s", "")));
		}
		if(rb_qianxin_zhengchang.isChecked()){
			nbc.setBoch_bregma_choi(1);
		}
		else if(rb_qianxin_penglong.isChecked()){
			nbc.setBoch_bregma_choi(2);
		}
		else if(rb_qianxin_aoxian.isChecked()){
			nbc.setBoch_bregma_choi(3);
		}
		else if(rb_qianxin_other.isChecked()){
			nbc.setBoch_bregma_choi(4);
			nbc.setBoch_bregma_other(et_qianxin_other.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_yanwaiguan_no.isChecked()){
			nbc.setBoch_eye_appearance(1);
		}
		else if(rb_yanwaiguan_yes.isChecked()){
			nbc.setBoch_eye_appearance(2);
			nbc.setBoch_eye_appearance_abn(et_yanwaiguan_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_sizhi_no.isChecked()){
			nbc.setBoch_legs(1);
		}
		else if(rb_sizhi_yes.isChecked()){
			nbc.setBoch_legs(2);
			nbc.setBoch_legs_abn(et_sizhi_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_ear_no.isChecked()){
			nbc.setBoch_ear_appearance(1);
		}
		else if(rb_ear_yes.isChecked()){
			nbc.setBoch_ear_appearance(2);
			nbc.setBoch_ear_appearance_abn(et_ear_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_jbbk_no.isChecked()){
			nbc.setBoch_neck_mass(1);
		}
		else if(rb_jbbk_yes.isChecked()){
			nbc.setBoch_neck_mass(2);
			nbc.setBoch_neck_mass_abn(et_jbbk_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_nose_no.isChecked()){
			nbc.setBoch_nose(1);
		}
		else if(rb_nose_yes.isChecked()){
			nbc.setBoch_nose(2);
			nbc.setBoch_nose_abn(et_nose_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_skin_no.isChecked()){
			nbc.setBoch_skin(1);
		}
		else if(rb_skin_shizhen.isChecked()){
			nbc.setBoch_skin(2);
		}
		else if(rb_skin_milan.isChecked()){
			nbc.setBoch_skin(3);
		}
		else if(rb_skin_other.isChecked()){
			nbc.setBoch_skin(4);
		}
		if(rb_oral_no.isChecked()){
			nbc.setBoch_oral(1);
		}
		else if(rb_oral_yes.isChecked()){
			nbc.setBoch_oral(2);
			nbc.setBoch_oral_abn(et_oral_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_gangmen_no.isChecked()){
			nbc.setBoch_anus(1);
		}
		else if(rb_gangmen_yes.isChecked()){
			nbc.setBoch_anus(2);
			nbc.setBoch_anus_abn(et_gangmen_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_card_no.isChecked()){
			nbc.setBoch_card(1);
		}
		else if(rb_card_yes.isChecked()){
			nbc.setBoch_card(2);
			nbc.setBoch_card_abn(et_card_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_wszq_no.isChecked()){
			nbc.setBoch_genital(1);
		}
		else if(rb_wszq_yes.isChecked()){
			nbc.setBoch_genital(2);
			nbc.setBoch_genital_abn(et_wszq_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_fubu_no.isChecked()){
			nbc.setBoch_abdomen(1);
		}
		else if(rb_fubu_yes.isChecked()){
			nbc.setBoch_abdomen(2);
			nbc.setBoch_abdomen_abn(et_fubu_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_jizhu_no.isChecked()){
			nbc.setBoch_spine(1);
		}
		else if(rb_jizhu_yes.isChecked()){
			nbc.setBoch_spine(2);
			nbc.setBoch_spine_abn(et_jizhu_yes.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_qibu_weituo.isChecked()){
			nbc.setBoch_umbilical(1);
		}
		else if(rb_qibu_tuoluo.isChecked()){
			nbc.setBoch_umbilical(2);
		}
		else if(rb_qibu_youshenchu.isChecked()){
			nbc.setBoch_umbilical(3);
		}
		else if(rb_qibu_other.isChecked()){
			nbc.setBoch_umbilical(4);
			nbc.setBoch_umbilical_other(et_qibu_other.getText().toString().replaceAll("\\s", ""));
		}
		if(rb_zhuanzhen_no.isChecked()){
			nbc.setBoch_refe_choi(1);
		}
		else if(rb_zhuanzhen_yes.isChecked()){
			nbc.setBoch_refe_choi(2);
			nbc.setBoch_refe_reasion(et_zhuanzhen_reason.getText().toString().replaceAll("\\s", ""));
			nbc.setBoch_refe_inst(et_zhuanzhen_inst.getText().toString().replaceAll("\\s", ""));
		}
		String s="";
		if(cb_weiyang.isChecked()){
			s+="1,";
		}
		if(cb_fayu.isChecked()){
			s+="2,";
		}
		if(cb_fangbing.isChecked()){
			s+="3,";
		}
		if(cb_yufang.isChecked()){
			s+="4,";
		}
		if(cb_oral.isChecked()){
			s+="5,";
		}
		nbc.setBoch_guide(s);
		nbc.setBoch_now_date(et_now_date.getText().toString().replaceAll("\\s", ""));
		nbc.setBoch_next_place(et_next_place.getText().toString().replaceAll("\\s", ""));
		nbc.setBoch_next_date(et_next_date.getText().toString().replaceAll("\\s", ""));
		nbc.setBoch_doctor(et_doctor.getText().toString().replaceAll("\\s", ""));
		nbc.updateNewBornChild(profileid);
		
		return true;
	}

	class MyView extends View {
    	Paint paint;
    	
		public MyView(Context context) {
			super(context);
			paint=new Paint();
			paint.setStyle(Paint.Style.STROKE);
            paint.setColor(Color.BLACK);
		}
		
		@Override
		public void onDraw(Canvas c){
	        int top=ll1.getTop();
	        int left=ll1.getLeft()-15;
	        int right=ll1.getRight()+15;
	        int bottom=ll1.getBottom();
	        int y=0;//sv.getScrollY();
	        int height=rb_mianse_hongrun.getHeight();
	        int height2=et_mianse_other.getHeight();
	        top=top-y;
	        bottom=bottom-y;
	        
	        c.drawLine(left, top+122, right, top+122, paint);
	        c.drawLine(left, top+122+40+height2, right, top+122+40+height2, paint);
	        c.drawLine(left, top+122+40*2+height2*2, right, top+122+40*2+height2*2, paint);
	        c.drawLine(left, top+122+40*3+height2*3, right, top+122+40*3+height2*3, paint);
	        c.drawLine(left, top+122+40*4+height2*4, right, top+122+40*4+height2*4, paint);
	        c.drawLine(left, top+122+40*5+height2*5, right, top+122+40*5+height2*5, paint);
	        c.drawLine(left, top+122+40*6+height2*6, right, top+122+40*6+height2*6, paint);
	        c.drawLine(left, top+122+40*7+height2*7, right, top+122+40*7+height2*7, paint);
	        c.drawLine(left, top+122+40*8+height2*8, right, top+122+40*8+height2*8, paint);
	        c.drawLine(left, top+122+40*9+height2*9, right, top+122+40*9+height2*9, paint);
	        c.drawLine(left, top+142+40*10+height2*11+height, right, top+142+40*10+height2*11+height, paint);
	        c.drawLine(left, top+142+40*11+height2*11+height*2, right, top+142+40*11+height2*11+height*2, paint);
	        c.drawLine(left, top+142+40*12+height2*12+height*2, right, top+142+40*12+height2*12+height*2, paint);
	        c.drawLine(left, top+142+40*13+height2*13+height*2, right, top+142+40*13+height2*13+height*2, paint);
	        
	        c.drawLine(left, top+122, left, top+142+40*13+height2*13+height*2, paint);
	        c.drawLine(right, top+122, right, top+142+40*13+height2*13+height*2, paint);
	        
	        c.drawLine(left+365, top+122, left+365, top+122+40+height2, paint);
	        
	        c.drawLine(left+365, top+122+40*2+height2*2, left+365, top+122+40*8+height2*8, paint);
	        
	        c.drawLine(left+365, top+142+40*11+height2*11+height*2, left+365, top+142+40*13+height2*13+height*2, paint);
	        
		}
    	
    }

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v==et_now_date){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_newchild_now_date), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_now_date.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_next_date){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_newchild_next_date), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_next_date.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		
	}

	@Override
	public void onFocusChange(View v, boolean hasFocus) {
		// TODO Auto-generated method stub
		if(v==et_now_date&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_newchild_now_date), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_now_date.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_next_date&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_newchild_now_date), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_next_date.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
	}
	
	
}
